<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * then方法的作用，获取
          */
        let p = new Promise ((resolve, reject) => {
            // resolve('111')
            // reject('222')
            throw 3;
        }) .then ((value) => {
            console.log('value1---' + value);
            // 回调函数的结果为promise对象，没有调用reject和resolve，此时状态为pending,不会触发.then
            // return new Promise((resolve, reject) => {
            //     resolve('a1')
            // })
            // 回调函数的结果为非promise对象
            // return  5;
            // 抛出一个错误
            throw 6;
        }, (reason) => {
            console.log('reason1----' + reason);
        })
        let p1 = p.then((value) => {
            console.log('value2---' + value);
        }, reason => {
            console.log('reason2----' + reason);
        })
        console.log(p);// .then返回的promise对象 的状态
        console.log(p1);
    </script>
</body>
</html>
